package com.eight.clienthome.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.eight.clienthome.dao.EduCourseDao;
import com.eight.clienthome.service.EduCourseService;
import com.eight.clienthome.vo.AttentionVo;
import com.eight.common.pojo.EduCourse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * @author 向文豪
 * @program: eight-education-parent
 * @description:
 * @date 2023/6/5 17:33
 */
@Service
public class EduCourseServiceImpl implements EduCourseService {
    @Autowired
    private EduCourseDao eduCourseDao;
    @Override
    public Page<EduCourse> findCourseByTeacherId(Integer pageCurrent, Integer pageSize, AttentionVo attentionVo) {
        Page<EduCourse> page = new Page<>(pageCurrent, pageSize);
        QueryWrapper<EduCourse> wrapper = new QueryWrapper<>();
        if (StringUtils.hasText(attentionVo.getCourseName())){
            wrapper.like("title",attentionVo.getCourseName());
        }
        if (StringUtils.hasText(attentionVo.getTeacherId())){
            wrapper.eq("teacher_id",attentionVo.getTeacherId());
        }
        Page<EduCourse> eduCoursePage = eduCourseDao.selectPage(page, wrapper);
        return eduCoursePage;
    }
}
